package com.qipay.baas.mapper;

import com.qipay.baas.model.SpUser;
import com.qipay.baas.model.SpUserExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface SpUserMapper {
    @SelectProvider(type=SpUserSqlProvider.class, method="countByExample")
    int countByExample(SpUserExample example);

    @DeleteProvider(type=SpUserSqlProvider.class, method="deleteByExample")
    int deleteByExample(SpUserExample example);

    @Delete({
        "delete from `sp_user`",
        "where `id` = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into `sp_user` (`name`, `sp_user_name`)",
        "values (#{name,jdbcType=VARCHAR}, #{spUserName,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(SpUser record);

    @InsertProvider(type=SpUserSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insertSelective(SpUser record);

    @SelectProvider(type=SpUserSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="sp_user_name", property="spUserName", jdbcType=JdbcType.VARCHAR)
    })
    List<SpUser> selectByExampleWithRowbounds(SpUserExample example, RowBounds rowBounds);

    @SelectProvider(type=SpUserSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="sp_user_name", property="spUserName", jdbcType=JdbcType.VARCHAR)
    })
    List<SpUser> selectByExample(SpUserExample example);

    @Select({
        "select",
        "`id`, `name`, `sp_user_name`",
        "from `sp_user`",
        "where `id` = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="sp_user_name", property="spUserName", jdbcType=JdbcType.VARCHAR)
    })
    SpUser selectByPrimaryKey(Integer id);

    @UpdateProvider(type=SpUserSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SpUser record, @Param("example") SpUserExample example);

    @UpdateProvider(type=SpUserSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SpUser record, @Param("example") SpUserExample example);

    @UpdateProvider(type=SpUserSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SpUser record);

    @Update({
        "update `sp_user`",
        "set `name` = #{name,jdbcType=VARCHAR},",
          "`sp_user_name` = #{spUserName,jdbcType=VARCHAR}",
        "where `id` = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SpUser record);
}